package com.bart.hsp.scala.ch10.sec02

import java.io.Serializable

/**
 * 特质中不做实现的方法就是抽象方法
 */
trait Logger {
  def log(msg: String) // An abstract method
}

/**
 * 1、Logger with Cloneable with Serializable 是一个整体
 * 2、重写trait的方法不用添加 override关键词
 * 3、with 后面必须是接口
 */
class ConsoleLogger extends Logger // Use extends, not implements
  with Cloneable with Serializable { // Use with to add multiple traits
  def log(msg: String) { println(msg) } // No override needed不用添加 override关键词
}

object Main extends App {
  val logger = new ConsoleLogger
  logger.log("Exiting Main")
}
